import 'package:tender_flutter/page/home/model/common_tag_model.dart';

commonListTagModelFromJson(CommonListTagModel data, Map<String, dynamic> json) {
	if (json['pageNum'] != null) {
		data.pageNum = json['pageNum'] is String
				? int.tryParse(json['pageNum'])
				: json['pageNum'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['pages'] != null) {
		data.pages = json['pages'] is String
				? int.tryParse(json['pages'])
				: json['pages'].toInt();
	}
	if (json['list'] != null) {
		data.xList = new List<CommonTagModel>();
		(json['list'] as List).forEach((v) {
			data.xList.add(new CommonTagModel().fromJson(v));
		});
	}
	if (json['isFirstPage'] != null) {
		data.isFirstPage = json['isFirstPage'];
	}
	if (json['isLastPage'] != null) {
		data.isLastPage = json['isLastPage'];
	}
	return data;
}

Map<String, dynamic> commonListTagModelToJson(CommonListTagModel entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['pageNum'] = entity.pageNum;
	data['pageSize'] = entity.pageSize;
	data['total'] = entity.total;
	data['pages'] = entity.pages;
	if (entity.xList != null) {
		data['list'] =  entity.xList.map((v) => v.toJson()).toList();
	}
	data['isFirstPage'] = entity.isFirstPage;
	data['isLastPage'] = entity.isLastPage;
	return data;
}

commonTagModelFromJson(CommonTagModel data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.strId = json['id'].toString();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['value'] != null) {
		data.value = json['value'].toString();
	}
	if (json['isSelected'] != null) {
		data.isSelected = json['isSelected'];
	}
	return data;
}

Map<String, dynamic> commonTagModelToJson(CommonTagModel entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.strId;
	data['key'] = entity.key;
	data['title'] = entity.title;
	data['value'] = entity.value;
	data['isSelected'] = entity.isSelected;
	return data;
}